package com.itheima.health.controller;

import com.itheima.health.dto.CheckGroupDTO;
import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.CheckItem;
import com.itheima.health.service.CheckGroupService;
import com.itheima.health.service.CheckItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("checkgroup")
@Api(tags = "传智健康预约模块之检查组管理")
public class CheckGroupController {

    @Reference
    private CheckGroupService checkGroupService;

    // 修改 和 添加   判断   checkItem  有无和数据库记录相同 id
    @PostMapping("saveOrUpdate")
    public Result   saveOrUpdate(@RequestBody CheckGroupDTO checkGroupDTO){
        return  new Result(checkGroupService.saveOrUpdateGroup(checkGroupDTO));
    }

    @GetMapping("findGroupInfoById/{id}")
    public Result   findGroupInfoById(@PathVariable("id") int id){
        return  new Result(checkGroupService.findGroupInfoById(id));
    }
//
    @GetMapping("findAll")
    @ApiOperation(value = "查询功能",notes = "检查项查询列表信息")
    public Result   findAll(){
        return  new Result(checkGroupService.list());
    }
    @PostMapping("findPage")
    @ApiOperation(value = "查询功能",notes = "检查项查询列表信息")
    public Result   findPage(@RequestBody QueryPageBean queryPageBean){
        return  new Result(checkGroupService.findPage(queryPageBean));
    }
//
//    @DeleteMapping("delete/{id}")
//    @ApiOperation(value = "删除功能",notes = "根据id 删除指定检查项")
//    public Result   delete(@PathVariable("id") int id){
//        return  new Result(checkItemService.removeById(id));
//    }

}
